package com.atguigu.bean.mapper.mybatis.param;

import com.atguigu.bean.mapper.mybatis.bean.User;
import com.atguigu.bean.mapper.mybatis.mapper.ParamMapper;
import com.atguigu.bean.mapper.mybatis.utils.SqlsessionUtils;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author wk
 * @create 2021-05-27 16:23
 */
public class ParamTest {
    @Test
    public void testParam(){
        SqlSession sqlsession = SqlsessionUtils.getSqlsession();
        ParamMapper mapper = sqlsession.getMapper(ParamMapper.class);
        List<User> list = mapper.getUserList("詹姆斯");
        list.forEach(user -> System.out.println(user));

    }
    @Test
    public void testCheckLogin(){
        SqlSession sqlsession = SqlsessionUtils.getSqlsession();
        ParamMapper mapper = sqlsession.getMapper(ParamMapper.class);
        User user = mapper.checkLogin("艾弗森", "123456");
        System.out.println(user);
    }

    @Test
    public void testcheckLoginByMap(){
        SqlSession sqlsession = SqlsessionUtils.getSqlsession();
        ParamMapper mapper = sqlsession.getMapper(ParamMapper.class);
        Map<String,Object> map=new HashMap<>();
        map.put("username","艾弗森");
        map.put("password","123456");
        User user = mapper.checkLoginByMap(map);
        System.out.println(user);
    }
}
